//
//  UIBarButtonItem+mmjExtension.m
//  Social
//
//  Created by seirra on 2018/5/14.
//  Copyright © 2018年 mmj. All rights reserved.
//

#import "UIBarButtonItem+mmjExtension.h"

@implementation UIBarButtonItem (mmjExtension)
+(UIBarButtonItem *)itemwithimage:(NSString*)image highimage:(NSString *)highimage target:(id)target action :(SEL)action{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:image] forState:UIControlStateNormal
     ];
    [button setImage:[UIImage imageNamed:highimage] forState:UIControlStateHighlighted];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [button sizeToFit];
    return [[UIBarButtonItem alloc]initWithCustomView:button];
}
//+(UIBarButtonItem *)itemwithimageleft:(id)target action :(SEL)action
//{
//    //左上角
//    UIButton* backButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    [backButton setImage:[UIImage imageNamed: @"navigationButtonReturn"] forState:UIControlStateNormal];
//    [backButton setImage:[UIImage imageNamed: @"navigationButtonReturnClick"] forState:UIControlStateHighlighted];
//    [backButton setTitle:@"返回" forState:UIControlStateNormal];
//    [backButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//    [backButton setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
//    [backButton sizeToFit];
//    //    backButton.imageEdgeInsets = UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>);
//    //    backButton.titleEdgeInsets = UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>);
//    backButton.contentEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);//将button向右移动20
//    [backButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
//
//    return  [[UIBarButtonItem alloc]initWithCustomView:backButton];
//}

@end
